package com.un.web.topic.service.impl;

import cn.hutool.db.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.un.web.topic.domian.vo.TopicVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.un.web.topic.domian.entity.TopicJava;
import com.un.web.topic.mapper.TopicJavaMapper;
import com.un.web.topic.service.TopicJavaService;
/**
* @Author xingjian
* @Date 2023-02-01
**/

@Service
public class TopicJavaServiceImpl extends ServiceImpl<TopicJavaMapper, TopicJava> implements TopicJavaService{

    @Autowired
    private TopicJavaMapper topicJavaMapper;

    @Override
    public PageInfo<TopicJava> selectAllByPage(Page page) {
        PageHelper.startPage(page.getPageNumber(),page.getPageSize());
        List<TopicJava> topicJavas = topicJavaMapper.selectList(new QueryWrapper<TopicJava>().eq("check_status",1));
        return new PageInfo<>(topicJavas);
    }

    @Override
    public TopicVO selectOnefirst() {
        return topicJavaMapper.findOneFirst();
    }

    @Override
    public TopicVO selectOrderId(Integer id) {
        return topicJavaMapper.selectBigById(id);
    }

    @Override
    public TopicVO getNextTopic(Integer topicId) {
        return topicJavaMapper.selectNextTopic(topicId);
    }

}
